package org.krivtsun.scanlab;

import javax.swing.*;
import java.awt.*;

/**
 * @author Andrew Krivtsun
 */
class StatusBar {

    private JPanel panel = new JPanel(new GridBagLayout());
    private int i = 0;

    public StatusBar() {
        addImpl(new JPanel(), 0, 1,0, GridBagConstraints.HORIZONTAL);
        addSeparator();
    }

    public void addItem(JComponent comp) {
        comp.setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
        addImpl(comp, ++i, 0,0, GridBagConstraints.NONE);
    }

    public void addSeparator() {
        JSeparator sep = new JSeparator(JSeparator.VERTICAL);
        addImpl(sep, ++i, 0,1, GridBagConstraints.VERTICAL);
    }

    public Component getViewComponent() {
        return panel;
    }

    private void addImpl(JComponent comp, int gridX, double weightX, double weightY, int fill) {
        panel.add(comp, new GridBagConstraints(gridX,0, 1,1, weightX,weightY,
            GridBagConstraints.WEST, fill, new Insets(0,0,0,0), 0,0));
    }
}
